package application

import (
	"ruoyi-go-echo-ddd/internal/domain/model"
	"ruoyi-go-echo-ddd/internal/domain/service"
	"ruoyi-go-echo-ddd/internal/infrastructure/http/request"

	"github.com/labstack/echo/v4"
)

type SysMenuApplication struct {
	service *service.SysMenuService
}

func NewSysMenuApplication(u *service.SysMenuService) *SysMenuApplication {
	return &SysMenuApplication{
		service: u,
	}
}

func (s *SysMenuApplication) Insert(e echo.Context, dept *model.SysMenu) (*model.SysMenu, error) {
	return s.service.Insert(e.Request().Context(), dept)
}

func (s *SysMenuApplication) Update(e echo.Context, dept *model.SysMenu) (int64, error) {
	return s.service.Update(e.Request().Context(), dept)
}

func (s *SysMenuApplication) BatchInsert(e echo.Context, list []*model.SysMenu) ([]int64, error) {
	return s.service.BatchInsert(e.Request().Context(), list)
}

func (s *SysMenuApplication) SelectById(e echo.Context, id int64) (*model.SysMenu, error) {
	return s.service.SelectById(e.Request().Context(), id)
}

func (s *SysMenuApplication) SelectList(e echo.Context, param *request.MenuPageParam) ([]*model.SysMenu, error) {
	return s.service.SelectList(e.Request().Context(), param)
}

func (s *SysMenuApplication) SelectPage(e echo.Context, param *request.MenuPageParam) ([]*model.SysMenu, int64, int64, error) {
	return s.service.SelectPage(e.Request().Context(), param)
}

func (s *SysMenuApplication) BatchDelete(e echo.Context, ids []any) (int64, error) {
	return s.service.BatchDelete(e.Request().Context(), ids)
}

func (s *SysMenuApplication) SelectListByUserId(e echo.Context, userId int64, menuName, visible, beginTime, endTime string) ([]*model.SysMenu, error) {
	return s.service.SelectListByUserId(e.Request().Context(), userId, menuName, visible, beginTime, endTime)
}

func (s *SysMenuApplication) SelectMenuPermsByUserId(e echo.Context, userId int64) ([]string, error) {
	return s.service.SelectMenuPermsByUserId(e.Request().Context(), userId)
}

func (s *SysMenuApplication) SelectTreeAll(e echo.Context) ([]*model.SysMenu, error) {
	return s.service.SelectTreeAll(e.Request().Context())
}

func (s *SysMenuApplication) SelectTreeByUserId(e echo.Context, userId int64) ([]*model.SysMenu, error) {
	return s.service.SelectTreeByUserId(e.Request().Context(), userId)
}

func (s *SysMenuApplication) BuildMenus(menuList []*model.SysMenu) ([]*model.RouterVo, error) {
	return s.service.BuildMenus(menuList)
}

func (s *SysMenuApplication) BuildMenuTree(menuList []*model.SysMenu) ([]*model.SysMenu, error) {
	return s.service.BuildMenuTree(menuList)
}

func (s *SysMenuApplication) SelectListByMenuAndUserId(e echo.Context, menu *model.SysMenu, userId int64) ([]*model.SysMenu, error) {
	return s.service.SelectListByMenuAndUserId(e.Request().Context(), menu, userId)
}

func (s *SysMenuApplication) BuildMenuTreeSelect(menuList []*model.SysMenu) []*model.TreeSelect {
	return s.service.BuildMenuTreeSelect(menuList)
}

func (s *SysMenuApplication) BuildRoleMenuTreeSelect(e echo.Context, userId, roleId int64) (*model.RoleMenuTreeSelect, error) {
	return s.service.BuildRoleMenuTreeSelect(e.Request().Context(), userId, roleId)
}
